<script setup>
import BackLink from "@/components/BackLink/index.vue"
import {useRoute, useRouter} from "vue-router";
import {getActualOutPutListApi, getArchivesListApi, getStuDetailsApi} from "@/api/school.js";
import UserBaseInfo from "@/components/UserBaseInfo/index.vue";
import TableRender from "@/components/TableRender/index.vue";

const {proxy} = getCurrentInstance();

const router = useRouter()
const route = useRoute()
const state = reactive({
  studentInfo: {},
  tableData: [],
  queryParams: {
    pageNum: 1,
    pageSize: 3,
    stuId: '',
  },
  total: 0,
  curItem: {}
})

const getDataList = async () => {
  const res = await getArchivesListApi(state.queryParams)
  if (res.code == 200) {
    state.tableData = res.rows
    state.total = res.total
  }
}

const handleBack = () => {
  router.go(-1)
}

const getStuDetails = async () => {
  const res = await getStuDetailsApi({id: state.queryParams.stuId})
  if (res.code == 200) {
    state.studentInfo = res.data
  }
}

onMounted(() => {
  const id = route.query.stuId
  const type = route.query.type
  if (id && type) {
    state.queryParams.stuId = id
    state.queryParams.learningType = type
    getDataList()
    getStuDetails()
  } else {
    proxy.$modal.msgError("页面参数异常，请重新进入");
  }

})

</script>

<template>
  <div class="outBox">
    <el-card>
      <BackLink/>
      <div class="form-box">
        <UserBaseInfo :student-info="state.studentInfo"/>
        <div class="form-table">
          <div class="form-item">
            <div class="form-name">6211</div>
          </div>
          <TableRender v-for="item in state.tableData" :json-data="item.jsonData"/>
        </div>
        <div class="pageBox">
          <pagination
              v-show="state.total > 0"
              :total="state.total"
              v-model:page="state.queryParams.pageNum"
              v-model:limit="state.queryParams.pageSize"
              :layout="'total, prev, pager, next, jumper'"
              @pagination="getDataList()"
          />
        </div>
        <div class="center-btns">
          <el-button @click="handleBack" type="primary">返回</el-button>
        </div>
      </div>
    </el-card>

  </div>
</template>

<style scoped lang="scss">
.text-items {
  padding: 20px;
  display: grid;
  justify-content: space-between;
  grid-template-columns: repeat(2, 550px);

  .text-item {
    margin-bottom: 20px;
  }

  .tit {
    font-size: 22px;
    margin-bottom: 5px;
  }

  .bottom {
    display: flex;
    justify-content: space-between;

    .time {
      color: #827e7d;
    }
  }
}

.form-table {
  border: 1px solid #e5e5e5;
  min-height: 400px;

  table {
    margin-top: 20px;
  }
}

.center-btns {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.form-textArea {
  border: 1px solid #e5e5e5;
  min-height: 400px;

  :deep(.el-textarea) {
    --el-input-border-color: #fff !important;
    --el-input-focus-border: #fff !important;
    --el-input-hover-border-color: #fff !important;
    --el-input-focus-border-color: #fff !important;

  }
}

.form-box {
  .form-name {
    background: #f1f7ff;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    font-weight: bold;
    border-right: 1px solid #e5e5e5;
  }

  .form-line {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 1px solid #e5e5e5;
    margin-bottom: 20px;

    .form-item {
      display: flex;
      align-items: center;

      .form-cont {
        width: calc(100% - 100px);

        :deep(.el-input) {
          --el-input-border-color: #fff !important;
          --el-input-focus-border: #fff !important;
          --el-input-focus-border-color: #fff !important;
        }
      }
    }
  }
}
</style>
